package su.myspringapps.onlineschool.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * Класс-сущность Subscription
 * <p/>
 * Текущие подписки
 * <p/>
 *
 * @author petr.mikhailin
 * created 26.05.2024 14:36
 */
@Entity
@Data
@Table(name = "subscriptions")
@NoArgsConstructor
public class Subscription {

    @EmbeddedId
    private SubscriptionKey subscriptionKey = new SubscriptionKey();

    @ManyToOne(cascade = CascadeType.ALL)
    @MapsId("studentId")
    @JoinColumn(name = "student_id", referencedColumnName = "id")
    private Student student;

    @ManyToOne(cascade = CascadeType.ALL)
    @MapsId("courseId")
    @JoinColumn(name = "course_id", referencedColumnName = "id")
    private Course course;

    @Column(name = "subscription_date")
    private Date subscriptionDate;

}
